package com.nearby.android.unitl;

import java.util.HashMap;
import java.util.Map;

import android.content.Context;
import android.content.SharedPreferences;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.telephony.TelephonyManager;

public class Common{

	private static SharedPreferences preference;
	private static SharedPreferences.Editor editor;
	
	final static  String PREFERENCE_KEY = "com.nearby.android";
	
	//获取配置
	@SuppressWarnings("unchecked")
	public static Map<String, String> getServerSocketConfig(Context wrap){
		preference = wrap.getSharedPreferences(PREFERENCE_KEY, wrap.MODE_PRIVATE);
		HashMap<String, String> serverSocketConfig = new HashMap<String, String>();
		serverSocketConfig = (HashMap<String, String>) preference.getAll();
		return serverSocketConfig;
	}
	//获取手机号码
	public static String getPhoneNumber(Context wrap){
		TelephonyManager tManager = (TelephonyManager)wrap.getSystemService(wrap.TELEPHONY_SERVICE);
		String number = tManager.getLine1Number();
		return number;
	}
	//获取手机mac地址 
	public static String getPhoneMac(Context wrap){
		String macAddress = null;
		//String ip = null;
		WifiManager wifiMgr = (WifiManager) wrap.getSystemService(wrap.WIFI_SERVICE);
		WifiInfo info = ((null == wifiMgr) ? null : wifiMgr.getConnectionInfo());
		if(null != info){
			macAddress = info.getMacAddress();
			//ip = String.valueOf(info.getIpAddress());
		}
		return null;
	}
	
	
}
